package com.ruoyi.broker.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.broker.domain.BrokerApply;
import com.ruoyi.broker.service.IBrokerApplyService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 经纪人审核Controller
 * 
 * @author ruoyi
 * @date 2025-04-09
 */
@RestController
@RequestMapping("/brokerApply/brokerApply")
public class BrokerApplyController extends BaseController
{
    @Autowired
    private IBrokerApplyService brokerApplyService;

    /**
     * 查询经纪人审核列表
     */
    @PreAuthorize("@ss.hasPermi('brokerApply:brokerApply:list')")
    @GetMapping("/list")
    public TableDataInfo list(BrokerApply brokerApply)
    {
        startPage();
        List<BrokerApply> list = brokerApplyService.selectBrokerApplyList(brokerApply);
        return getDataTable(list);
    }

    /**
     * 导出经纪人审核列表
     */
    @PreAuthorize("@ss.hasPermi('brokerApply:brokerApply:export')")
    @Log(title = "经纪人审核", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BrokerApply brokerApply)
    {
        List<BrokerApply> list = brokerApplyService.selectBrokerApplyList(brokerApply);
        ExcelUtil<BrokerApply> util = new ExcelUtil<BrokerApply>(BrokerApply.class);
        util.exportExcel(response, list, "经纪人审核数据");
    }

    /**
     * 获取经纪人审核详细信息
     */
    @PreAuthorize("@ss.hasPermi('brokerApply:brokerApply:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(brokerApplyService.selectBrokerApplyById(id));
    }

    /**
     * 新增经纪人审核
     */
    @PreAuthorize("@ss.hasPermi('brokerApply:brokerApply:add')")
    @Log(title = "经纪人审核", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BrokerApply brokerApply)
    {
        return toAjax(brokerApplyService.insertBrokerApply(brokerApply));
    }

    /**
     * 修改经纪人审核
     */
    @PreAuthorize("@ss.hasPermi('brokerApply:brokerApply:edit')")
    @Log(title = "经纪人审核", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BrokerApply brokerApply)
    {
        return toAjax(brokerApplyService.updateBrokerApply(brokerApply));
    }

    /**
     * 删除经纪人审核
     */
    @PreAuthorize("@ss.hasPermi('brokerApply:brokerApply:remove')")
    @Log(title = "经纪人审核", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(brokerApplyService.deleteBrokerApplyByIds(ids));
    }
}
